package com.kyd.auth.controller;

import com.kyd.auth.service.DriverAccountService;
import com.kyd.base.response.Ret;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhuangqi
 * @date 2019-03-27
 */
@RestController
public class AuthController {


    @Autowired
    private DriverAccountService driverAccountService;


    @PostMapping(value = "/register")
    public Ret register(@RequestParam String phone, @RequestParam String password) {
        driverAccountService.register(phone, password);
        return Ret.ok();
    }

    @PostMapping(value = "/login")
    public Ret login(@RequestParam String phone, @RequestParam String password) {
        return Ret.ok(driverAccountService.login(phone, password));
    }

    @PostMapping(value = "/verify")
    public Ret verify(@RequestParam String token) {
        return Ret.ok().data(driverAccountService.verify(token));
    }

}
